﻿#region Summary

// 
// Owner : JackieHan 
// 
// Solution : Pharyngitis 
// 
// Project : TTrip.Pharyngitis.NHibernate
// 
// File : CoolDomainMapper.cs
// 
// CopyRight : Copyright © 2010-2011 Skomart Corporation, All Rights Reserved 
// 
// Summary : 自定义的实体Mapper
// 
// History : 
//			2012-03-21 11:05:46	    Create 
// 

#endregion

#region Using

using ConfOrm;
using ConfOrm.NH;
using ConfOrm.Patterns;
using ConfOrm.Shop.Appliers;
using ConfOrm.Shop.CoolNaming;

#endregion

namespace Jackie.Utility.NHibernate
{
    ///<summary>
    ///自定义的实体Mapper
    ///</summary>
    public class CoolDomainMapper : IDomainMapper
    {
        private readonly ObjectRelationalMapper orm;
        private readonly Mapper mapper;

        public CoolDomainMapper()
        {
            orm = new ObjectRelationalMapper();

            orm.Patterns.PoidStrategies.Add(new HighLowPoidPattern());
            orm.Patterns.Versions.Add(new VersionPattern());
            var patternsAppliers = new CoolPatternsAppliersHolder(orm);
            patternsAppliers.Merge(new DatePropertyByNameApplier()).Merge(new MsSQL2008DateTimeApplier());

            mapper = new Mapper(orm, patternsAppliers);
        }

        public ObjectRelationalMapper DomainDefinition
        {
            get { return orm; }
        }

        public Mapper Mapper
        {
            get { return mapper; }
        }
    }
}